

from django import forms
from login.models import User


class RegisterForm(forms.ModelForm):

    # 确认密码
    confirm_password = forms.CharField(label='确认密码',widget=forms.TextInput(attrs={'class': 'layui-input', 'placeholder': '请再次确认密码','lay-verify':"required"}))

    class Meta:
        model = User
        fields = ['username','password']

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            field.widget.attrs = {"class": "layui-input", "placeholder": "请输入" + field.label,'lay-verify':"required"}

